// 导入组件
import Vue from 'vue';
import Router from 'vue-router';

const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}

const VueRouterReplace = Router.prototype.replace
Router.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => err)
}

// 启用路由
Vue.use(Router);

// 导出路由 
export default new Router({
    mode: 'history',
    routes: [{
            path: '/',
            name: '',
            component: () =>
                import ('../views/login.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        }, {
            path: '/login',
            name: '登录',
            component: () =>
                import ('../views/login.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/register',
            name: '注册',
            component: () =>
                import ('../views/register.vue'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/index',
            name: '首页',
            component: () =>
                import ('../views/index.vue'),
            iconCls: 'el-icon-tickets',
            children: [{
                    path: '/varity/brand',
                    name: 'Brand',
                    component: () =>
                        import ('../views/varity/brand.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/varity/varity',
                    name: 'Varity',
                    component: () =>
                        import ('../views/varity/varity.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/user',
                    name: 'User',
                    component: () =>
                        import ('../views/user/index.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/userDetail',
                    name: 'UserDetail',
                    component: () =>
                        import ('../views/user/user.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/order',
                    name: 'Order',
                    component: () =>
                        import ('../views/order/index.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/comment',
                    name: 'Comment',
                    component: () =>
                        import ('../views/comment/index.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/complain',
                    name: 'Complain',
                    component: () =>
                        import ('../views/comment/complain.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/goods/recommend',
                    name: 'Recommend',
                    component: () =>
                        import ('../views/goods/recommend.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/goods/sellGoods',
                    name: 'SellGoods',
                    component: () =>
                        import ('../views/goods/sellGoods.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/daity/subway',
                    name: 'DaityDaity',
                    component: () =>
                        import ('../views/daity/subway.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/daity/local',
                    name: 'DaityComment',
                    component: () =>
                        import ('../views/daity/local.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/charts/custom',
                    name: 'Custom',
                    component: () =>
                        import ('../views/charts/custom.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/charts/product',
                    name: 'Product',
                    component: () =>
                        import ('../views/charts/product.vue'),
                    meta: {
                        requireAuth: true
                    }
                },
                {
                    path: '/charts/sell',
                    name: 'Sell',
                    component: () =>
                        import ('../views/charts/sell.vue'),
                    meta: {
                        requireAuth: true
                    }
                }
            ]
        }
    ]
})